package com.shenmazong.controller;

import com.shenmazong.utils.VerifyCodeUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletResponse;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2022/2/12 11:43
 */

@Controller
public class VerifyCodeController {

    // 默认验证码
    @GetMapping(value = "/code1")
    public String code1(HttpServletResponse response) {
        String code = VerifyCodeUtil.code().getCode(response);
        // 把验证码放入redis
        System.out.println("code1="+code);
        return code;
    }

    // 调试模式
    @GetMapping(value = "/code2")
    public String code2(HttpServletResponse response) {
        String code = VerifyCodeUtil.code().getCode(response, "1234");
        // 把验证码放入redis
        System.out.println("code2="+code);
        return code;
    }

    // 调试模式
    @GetMapping(value = "/code3")
    public String code3(HttpServletResponse response) {
        String code = VerifyCodeUtil.code().setLength(6).getCode(response);
        // 把验证码放入redis
        System.out.println("code3="+code);
        return code;
    }

    // 设置随机字典
    @GetMapping(value = "/code4")
    public String code4(HttpServletResponse response) {
        String code = VerifyCodeUtil.code().setRandText("ABCD%").getCode(response);
        // 把验证码放入redis
        System.out.println("code4="+code);
        return code;
    }

    // 设置验证码图片的大小
    @GetMapping(value = "/code5")
    public String code5(HttpServletResponse response) {
        String code = VerifyCodeUtil.code().setSize(200, 80).getCode(response);
        // 把验证码放入redis
        System.out.println("code5="+code);
        return code;
    }
}
